package org.terrier.matching.models.basicmodel;

import org.terrier.utility.ApplicationSetup;

public class S extends BasicModel {
	double alpha = Double.parseDouble(ApplicationSetup.getProperty("distribution.parameter.0", "1.1"));
    double beta = Double.parseDouble(ApplicationSetup.getProperty("distribution.parameter.1", "0.5"));

	@Override
	public String getInfo() {
		return "S"+alpha+"_"+beta+"_";
	}

	@Override
	public double score(double tf, double documentFrequency,
			double termFrequency, double keyFrequency, double documentLength) {

		return keyFrequency * Math.pow(tf,(1+beta)) / (alpha + tf);
		
	}
	
	public void initModel(){
		String value = null;
		if ((value = ApplicationSetup.getProperty("distribution.parameter.0", "1.1d"))!=null){
			this.alpha = Double.parseDouble(value);
		}
		if ((value = ApplicationSetup.getProperty("distribution.parameter.1", "0.5d"))!=null){
			this.beta = Double.parseDouble(value);
		}
	}

}
